package rpc

import (
	"github.com/gin-gonic/gin"
	"github.com/spf13/viper"
	"github.com/weibocom/motan-go"
	"github.com/weibocom/motan-go/core"
	"gitee.com/man0sions/IdCreator/service/rpc/provider"
)

type Test struct {
}

func NewRpc(engine *gin.Engine, Vp *viper.Viper,sid string) {
	msctx := motan.GetMotanServerContext(Vp.GetString("motan.conf"))
	ext := motan.GetDefaultExtFactory()
	ext.RegistExtProvider("proxy", func(url *core.URL) core.Provider {
		return provider.NewProxyProvider(engine, url, map[string]bool{})
	})
	msctx.RegisterService(&Test{}, sid)
	msctx.Start(nil)
	msctx.ServicesAvailable()
}
